﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Authors.aspx.cs" Inherits="Authors" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    <style type="text/css">
        .style1
        {
            font-size: x-large;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <h1 class="style1">
        <strong>Authors</strong></h1>
    <p>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="au_id" DataSourceID="SqlDataSource1" 
        EmptyDataText="There are no data records to display." Width="758px" 
            AllowPaging="True">
        <Columns>
            <asp:BoundField DataField="au_lname" HeaderText="Last Name" 
                SortExpression="au_lname" ReadOnly="True" />
            <asp:BoundField DataField="au_fname" HeaderText="First Name" 
                SortExpression="au_fname" ReadOnly="True" />
            <asp:BoundField DataField="phone" HeaderText="Phone" SortExpression="phone" />
            <asp:HyperLinkField DataNavigateUrlFields="au_id" 
                DataNavigateUrlFormatString="~/AuthorUpdate.aspx?au_id={0}" Text="Edit" />
            <asp:CommandField ShowDeleteButton="True" />
        </Columns>
    </asp:GridView>
        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/AuthorInsert.aspx">Create new Author</asp:HyperLink>
    <br />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:mybookstoreConnectionString1 %>" 
        DeleteCommand="DELETE FROM [authors] WHERE [au_id] = @au_id" 
        InsertCommand="INSERT INTO [authors] ([au_lname], [au_fname], [phone], [address], [city], [state], [zip]) VALUES (@au_lname, @au_fname, @phone, @address, @city, @state, @zip)" 
        ProviderName="<%$ ConnectionStrings:mybookstoreConnectionString1.ProviderName %>" 
        SelectCommand="SELECT [au_id], [au_lname], [au_fname], [phone], [address], [city], [state], [zip] FROM [authors] ORDER BY [au_lname]" 
        UpdateCommand="UPDATE [authors] SET [phone] = @phone WHERE [au_id] = @au_id">
        <DeleteParameters>
            <asp:Parameter Name="au_id" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="au_lname" Type="String" />
            <asp:Parameter Name="au_fname" Type="String" />
            <asp:Parameter Name="phone" Type="String" />
            <asp:Parameter Name="address" Type="String" />
            <asp:Parameter Name="city" Type="String" />
            <asp:Parameter Name="state" Type="String" />
            <asp:Parameter Name="zip" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="phone" Type="String" />
            <asp:Parameter Name="au_id" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
</p>
</asp:Content>

